package Controller.UserController;

import Utils.BaseMessage;
import Utils.isString;
import ViewOption.userVo;
import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "getUsersAdminServlet", urlPatterns = {
        "/api/User/isAdmin/getUsersAdminServlet"
})
public class getUsersAdminServlet extends HttpServlet {
    private final isString isString = new isString();
    private final userVo userVo = new userVo();

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        if (isString.IsEmpty(request.getParameter("pageIndex"))) {
            response.getWriter().print(JSON.toJSONString(new BaseMessage(2, "非法传参", null)));
            return;
        }
        response.getWriter().print(JSON.toJSONString(userVo.getUsersIsAdminBySelective(request)));
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
